﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SDCWeb.DB;

namespace SDCWeb.Controllers
{
    public class HomeController : Controller
    {
        BaseDao dao = new BaseDao();
        public ActionResult Index()
        {
            string sql = "select * from t_d_message";
            List<Dictionary<string, object>> MessageList = new List<Dictionary<string, object>>();
            MessageList = dao.GetList(sql, new string[] { "messageid", "content" });
            ViewBag.MessageList = Newtonsoft.Json.JsonConvert.SerializeObject(MessageList);
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }


        public ActionResult API_GetData()
        {
            string sql = "select * from t_d_Device where DeviceId<>3 order by DeviceId";
            List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
            list = dao.GetList(sql, new string[] { "DeviceId", "DeviceName", "P", "Q", "Uab", "Iflc", "KD","ZS" });
            return Json(list, JsonRequestBehavior.AllowGet);
        }

        public ActionResult API_GetRiverData()
        {
            string sql = "select * from t_d_river where riverId=1";
            List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
            list = dao.GetList(sql, new string[] { "SBZ", "XCQC", "XCJSJ", "JCQC", "JCJSJ" });
            return Json(list, JsonRequestBehavior.AllowGet);
        }


    }
}